Skip to content

validate analytics event properties before sending - #23821

Closed
IDCs wants to merge 1 commit into
masterfrom
task/laz-862
Closed

validate analytics event properties before sending#23821
IDCs wants to merge 1 commit into
masterfrom
task/laz-862

Conversation

@IDCs

@IDCs IDCs commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

MixpanelEvent.properties is Record<string, any> and most event classes forward caller input verbatim, so nothing stopped a malformed payload reaching Mixpanel. A collections_installation_failed row arrived in 2.4.0 carrying only {"0":"4",...} — a bare id string spread into an object — with none of its real properties.

Add zod contracts for the collection-install and mod-install families, validated at the single send boundary in trackEvent. Unknown keys are stripped rather than rejected; nothing read from download metadata is required, since those ids come through optional chaining and parseInt and are legitimately absent for bundled and direct downloads. Garbage is caught by requiring at least one recognized property to survive. Events without a contract are still sent unvalidated.

part of LAZ-862

MixpanelEvent.properties is Record<string, any> and most event classes
forward caller input verbatim, so nothing stopped a malformed payload
reaching Mixpanel. A collections_installation_failed row arrived in
2.4.0 carrying only {"0":"4",...} — a bare id string spread into an
object — with none of its real properties.

Add zod contracts for the collection-install and mod-install families,
validated at the single send boundary in trackEvent. Unknown keys are
stripped rather than rejected; nothing read from download metadata is
required, since those ids come through optional chaining and parseInt
and are legitimately absent for bundled and direct downloads. Garbage
is caught by requiring at least one recognized property to survive.
Events without a contract are still sent unvalidated.

part of LAZ-862
@IDCs IDCs self-assigned this Jul 29, 2026
@IDCs
IDCs requested a review from a team as a code owner July 29, 2026 11:54

@erri120 erri120 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change we now have three different places where the define a event contract:

  1. Mixpanel Lexicon
  2. This new runtime schema
  3. The existing MixpanelEvent type and classes implementing it for typechecking

The issue is that these are not linked in any way. Making a change to the Mixpanel Lexicon doesn't impact our event classes, changing the runtime schema doesn't give us typechecking issues during development and changing the event classes won't pass validation without changing the new schema as well.

Since the linked ticket LAZ-862 is about malformed data reaching Mixpanel, I suggest checking if Mixpanel has a "strict" mode that rejects data not fitting the Lexicon. While we can change things in Vortex, users would actually have to run the latest version to send "valid" data, old versions of Vortex would continue sending malformed data.

As for what we can do inside Vortex, if we want to make sure we're only sending valid data as part of a schema, both the runtime and typechecking schemas should be the same, ie using zod and exporting both the Zod schema as a JavaScript object and a TypeScript type so that we get validation on all stages.

@IDCs

IDCs commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Nope - governance/workarounds for this will have to happen on the mixpanel/server side.

@IDCs IDCs closed this Jul 30, 2026
@erri120
erri120 deleted the task/laz-862 branch July 30, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants